import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { LoginComponent } from './pages/login/login.component';
import { AuthGuard } from './shared/auth/auth.guard';
import { LayoutComponent } from './pages/layout/layout.component';
import { RegisterComponent } from './pages/register/register.component';
import { WelcomeComponent } from './pages/welcome/welcome.component';
import { ForgetComponent } from './pages/forget/forget.component';

const routes: Routes = [
  {path: 'login', component: LoginComponent},
  {path: 'register', component: RegisterComponent},
  {path: 'forget', component: ForgetComponent},
  {
    path: '', component: LayoutComponent,
    canActivate: [AuthGuard], children: [
      {path: '', component: WelcomeComponent},
      {path: 'user', loadChildren: () => import('./pages/user/user.module').then(m => m.UserModule)},
      {path: 'book', loadChildren: () => import('./pages/book/book.module').then(m => m.BookModule)},
    ],
  },
  {path: '**', redirectTo: ''},
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
})
export class AppRoutingModule {
}
